<?php
// Lets build some response functions
function GenericResponseJSON($statusCode, $statusMessage)
{
    $response = new Response(new GenericResponse(new Status($statusCode,$statusMessage)));

    return json_encode($response);
}

function LoginResponseJSON($statusCode, $statusMessage, $userid, $sessionid)
{
    $response = new Response(new LoginResponse(new Status($statusCode,$statusMessage), new Login($userid,$sessionid)));
    return json_encode($response);
}

function ArrayProjectResponseJSON($statusCode,$statusMessage,$ProjectArray)
{
  $response = new Response(new ArrayProjectResponse(new Status($statusCode, $statusMessage), $ProjectArray));   
  return json_encode($response);
}

function ProjectResponseJSON($statusCode,$statusMessage,$id,$name,$desc,$start,$end,$daysleft, $done,$budget,$status)
{
  $response = new Response(new ProjectResponse(new Status($statusCode, $statusMessage), new Project($id, $name,$desc,$start,$end,$daysleft,$done,$budget,$status)));   
  return json_encode($response);
}

function ArrayMilestonesResponseJSON($statusCode, $statusMessage, $ArrayOfMilestones)
{
  $response = new Response(new ArrayMilestoneResponse(new Status($statusCode, $statusMessage), $ArrayOfMilestones));
  return json_encode($response);
}

function MilestonesResponseJSON($statusCode, $statusMessage, $id,$pid,$name,$desc,$start,$end,$status)
{
  $response = new Response(new MilestoneResponse(new Status($statusCode, $statusMessage), new Milestone($id,$pid,$name,$desc,$start,$end,$status)));
  return json_encode($response);
} 

function ArrayTasklistResponseJSON($statusCode, $statusMessage, $ArrayOfTasklists)
{
  $response = new Response(new ArrayTasklistResponse(new Status($statusCode, $statusMessage), $ArrayOfTasklists));
  return json_encode($response);
}

function TasklistResponseJSON($statusCode, $statusMessage, $tlid, $pid, $mid, $name, $desc, $start, $status, $access)
{
  $response = new Response(new TasklistResponse(new Status($statusCode, $statusMessage),new Tasklist( $tlid, $pid, $mid, $name, $desc, $start, $status, $access)));
  return json_encode($response);
}

function ArrayTasksResponseJSON($statusCode, $statusMessage, $ArrayOfTasks)
{
  $response = new Response(new ArrayTaskResponse(new Status($statusCode, $statusMessage), $ArrayOfTasks));
  return json_encode($response);
}

function TasksResponseJSON($statusCode, $statusMessage, $id,$pid,$tlid,$name,$desc,$start,$end,$status)
{
    
  $response = new Response(new TaskResponse(new Status($statusCode, $statusMessage), new Task($id,$pid,$tlid,$name,$desc,$start,$end,$status)));
  return json_encode($response);
}

function UsersResponseJSON($statusCode, $statusMessage, $ArrayOfUsers)
{
  $response = new Response(new UsersResponse(new Status($statusCode, $statusMessage), $ArrayOfUsers));
  return json_encode($response);
} 



function RoleResponseJSON($statusCode, $statusMessage, $name, $project, $tasks, $milestones, $messages, $files, $timetracker, $chat, $admin)
{
    $response = new Response(new RoleResponse(new Status($statusCode, $statusMessage),
                                              $name,
                                              new Role($project['add'],$project['edit'],$project['del'],$project['close'],$project['read']),
                                              new Role($tasks['add'],$tasks['edit'],$tasks['del'],$tasks['close'],$tasks['read']),
                                              new Role($milestones['add'],$milestones['edit'],$milestones['del'],$milestones['close'],$milestones['read']),
                                              new Role($messages['add'],$messages['edit'],$messages['del'],$messages['close'],$messages['read']),
                                              new Role($files['add'],$files['edit'],$files['del'],$files['close'],$files['read']),
                                              new Role($timetracker['add'],$timetracker['edit'],$timetracker['del'],$timetracker['close'],$timetracker['read']),
                                              new Role($chat['add'],$chat['edit'],$chat['del'],$chat['close'],$chat['read']),
                                              new Role($admin['add'],$admin['edit'],$admin['del'],$admin['close'],$admin['read'])
                 ));
    return json_encode($response);
}

function ValidateResponseJSON($statusCode, $statusMessage, $OWNER,$MAJOR, $MINOR, $BUILD, $TYPE, $MESSAGE)
{
        $response = new Response(new ValidateResponse(new status($statusCode,$statusMessage),
                                                       new Version($OWNER,$MAJOR,$MINOR,$BUILD, $TYPE, $MESSAGE)
                ));
       return json_encode($response);
}
?>
